package com.stwitinc.redmine;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.stwitinc.Util;
import com.stwitinc.netease.client.NeteaseClient;


public class NeteaseUtil
{
	public static String tpl_tooManyTasks="3064797";
	
	public JSONObject informForTooManyTasks(String name, String mobile, String content) 
	{

		JSONObject retData = new JSONObject();
		try
		{
			NeteaseClient client = new NeteaseClient();
			if (client != null)
			{

				JSONArray array = new JSONArray();
				array.add(mobile);

				String mobilesJsonString = array.toJSONString();
				//Log.info("mobilesJsonString:" + mobilesJsonString);

				JSONArray arrayForParams = new JSONArray();
				arrayForParams.add(name);
				arrayForParams.add(content);


				String paramsJsonString = arrayForParams.toJSONString();
				//Log.info("paramsJsonString:" + paramsJsonString);

				String strRet = client.sendTemplateMessage(NeteaseUtil.tpl_tooManyTasks, mobilesJsonString, paramsJsonString);

				if (!Util.isNullOrEmpty(strRet))
				{
					JSONObject objRet = JSONObject.parseObject(strRet);
					if (objRet != null)
					{
						int code = objRet.getInteger("code");
						switch (code)
						{
						case 200:// 操作成功
							retData.put("processResult", "true");
							break;

						default:
							retData.put("processResult", "false");
							retData.put("errorMessage", code + ":"+"发短信出错。");
							break;
						}

					}
				}
			}
		}
		catch (Exception exception)
		{

		}

		return retData;
	}

	
}
